<script setup lang="ts">
// 子组件接受参数--
type Props = {
  title?: string;
  isPopup?: boolean;
};
let prop = withDefaults(defineProps<Props>(), {
  title: "标题头",
  isPopup: false,
});

// 子组件接受参数==
const emits = defineEmits<{
  (e: "update:isPopup", value: boolean): void;
}>();
</script>

<template>
  <!-- 封装公共的弹窗样式 -->
  <div class="popup" v-show="isPopup">
    <!-- 内容区域 -->
    <div class="content">
      <!-- 头部关闭投诉窗口 -->
      <div class="header">
        <span class="title">{{ title }}</span>
        <span class="close" @click="emits('update:isPopup', false)"
          >&#xeca0;</span
        >
      </div>

      <!-- 使用插槽了 -->
      <slot>使用插槽了</slot>
    </div>
  </div>
</template>

<style scoped lang="scss">
.popup {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background-color: rgba(0, 0, 0, 0.49);
  @include flexCenterCenter;
  color: #fff;
}

.content {
  min-width: 200px;
  min-height: 200px;
  background-color: #fff;
  padding: 24px;
  border-radius: 4px;
}

// 头部内容
.header {
  width: 100%;
  font-size: 16px;
  font-family: PingFangSC-Semibold, PingFang SC;
  font-weight: 600;
  color: #303133;
  @include flexBetweenCenter;
}

// 标题头内容
.title {
  @include flexCenter;
  &::before {
    content: "";
    display: inline-block;
    width: 4px;
    height: 14px;
    background: #0066cc;
    border-radius: 1px;
    margin-right: 4px;
  }
}

// 关闭按钮
.close {
  width: 16px;
  height: 16px;
  color: #c0c4cc;
  cursor: pointer;
  background: transparent;
  user-select: none;
  @include flexCenterCenter;
  font-size: 16px;
}
</style>
